package day03;
/**赋值运算符演示*/
public class OperDemo4 {
    public static void main(String[] args) {
        //4）赋值运算符：=、+=、-=、*=、/=、%= (自带强转类型)
        int  a = 5;
        a += 10;  //相当于 a =(int)(a+10);
        System.out.println(a);  //15
        a *= 2;  //相当于 a =(int)(a*2);
        System.out.println(a);  //30
        a /= 6;  //相当于 a =(int)(a/6);
        System.out.println(a);  //5
        a -= 3;  //相当于 a = (int)(a-3);
        System.out.println(a);  //2
        a %= 2;  //相当于 a = (int)(a%2);
        System.out.println(a);  //0

        //小面试题：
        short s = 5;
        //s = s + 10;  //编译错误，需强转，改为s = (short)(s+10);
        s += 10;  //相当于s=(short)(s+10);
    }
}
